package com.xudu.utils;

/**
 * ClassName: Resoult
 * Description:
 *
 * @Author xudu
 * @Create 2024/4/8
 */

import com.xudu.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 返回前端页面的工具类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Resoult {

    /**
     * 返回状态码
     */
    private int code;
    /**
     * 返回信息
     */
    private String message;
    /**
     * 返回数据
     */
    private Object data;

    private String token;

    /**
     * 登陆成功不返回数据
     * @return
     */
    public static Resoult success(){
        Resoult resoult = new Resoult();
        resoult.setCode(200);
        resoult.setMessage("登陆成功！");

        return resoult;
    }

    /**
     * 登陆成功返回数据
     * @param data
     * @return
     */
    public  static Resoult success(Object data,String token){
        Resoult resoult = new Resoult();
        resoult.setCode(200);
        resoult.setMessage("登陆成功！");
        resoult.setData(data);
        resoult.setToken(token);
        return resoult;
    }


    /**
     * 登陆错误返回相关信息
     * @param message
     * @return
     */
    public  static Resoult error(String message){
        Resoult resoult = new Resoult();
        resoult.setCode(400);
        resoult.setMessage(message);

        return resoult;
    }
}
